package com.eveinfo.update;

import java.util.Timer;
import java.util.TimerTask;

import com.eveinfo.EveInfo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class UpdateService extends Service {

	private static final long START_DELAY = 3600000;
	private static final long UPDATE_INTERVAL = 3600000;

	private Timer timer = new Timer();

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		timer.scheduleAtFixedRate(new TimerTask() {
			public void run() {
				EveInfo.getData().update();
			}
		}, START_DELAY, UPDATE_INTERVAL);
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		if (timer != null)
			timer.cancel();
	}

}
